<?php echo get_header(); ?>
<form action="" method="get" id="user_index">

    <div class="row">
        <div class="col-lg-12">
            <div class="card">
                <div class="card-header">
                    <i class="fa fa-list-ul"></i> 角色管理
                </div>

                <div class="card-block">
                    <div class="p-b-2" >
                        <a href="#<?php echo url_for('/users/?action=add'); ?>" class="btn btn-success btn-sm"><i class="fa fa-plus"></i> 添加角色</a>
                        <div class="pull-right">

                        </div>
                        <!-- /.pull-right -->
                    </div>
                    <div class="table-responsive">
                        <table class="table table-bordered table-striped with-check" id="dataTable">
                            <thead class="thead-default">
                                <tr>
                                    <th><input type="checkbox" id="chk-all"></th>
                                    <th>角色名</th>
                                    <th>描述</th>                                                                
                                    <th>操作</th>
                                </tr>
                            </thead>
                            <tbody>
                                <?php 
                                foreach ($roles as $role) {
                                    ?>
                                    <tr>
                                        <td><input type="checkbox" class="chk-row"  name="users[id]" value="<?php echo $role->id; ?>"></td>
                                        <td><a href="#<?php echo url_for('/users/roles.php', ['action' => 'edit', 'id' => $role->id]); ?>"><b><?php echo $role->title; ?></b></a></td>
                                        <td><?php echo $role->description; ?></td>                                                                                                                       
                                        <td>
                                            <a href="#<?php echo url_for('/users/roles.php', ['action' => 'edit', 'id' => $role->id]); ?>" ><i class="fa fa-edit"></i> 编辑</a> 
                                            <a href="#<?php echo url_for('/users/roles.php', ['action' => 'delete', 'id' => $role->id]); ?>" ><i class="fa fa-trash"></i> 删除</a>

                                        </td>
                                    </tr>
                                <?php } ?>

                            </tbody>
                        </table>
                        <!-- /.table -->
                        <div class="text-center">
<?php // echo $paginator->render();   ?>
                        </div>
                    </div>

                </div>



            </div>

        </div>
    </div>


</form>
<?php Lg\View\JsBlock::begin(Lg\View\Asset::BODY_END); ?>
<script>
    $(function () {
        $('#chk-all').click(function () {
            if ($(this).is(':checked')) {
                $('#dataTable').find('.chk-row').each(function () {
                    $(this).prop('checked', true);
                    $(this).parent().parent().parent().addClass('selected');
                });
            } else {
                $('#dataTable').find('.chk-row').each(function () {
                    $(this).prop('checked', false);
                    $(this).parent().parent().parent().removeClass('selected');
                });
            }
        });
    });
</script>
<?php Lg\View\JsBlock::end(); ?>
<?php echo get_footer(); ?>
